﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Account_Register : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        RegisterUser.ContinueDestinationPageUrl = Request.QueryString["ReturnUrl"];
       // RegisterUserWizardStep.DuplicateUserNameErrorMessage = "";
    }

    protected void RegisterUser_CreatedUser(object sender, EventArgs e)
    {
       // FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */);
        TextBox userNameTextBox = (TextBox)RegisterUserWizardStep.ContentTemplateContainer.FindControl("UserName");
        MembershipUser user = Membership.GetUser(userNameTextBox.Text);
        user.IsApproved = false;
        //user.RoleName = "users";
        Roles.AddUserToRole(userNameTextBox.Text, "users"); 
        Membership.UpdateUser(user);


        string continueUrl = RegisterUser.ContinueDestinationPageUrl;
        if (String.IsNullOrEmpty(continueUrl))
        {
            continueUrl = "~/Generator_v3.aspx";
        }
        Response.Redirect(continueUrl);
    }

}
